#pragma once
#include "Singleton.h"
#include <functional>
#include <map>
#include "NumericCodeGenerator.h"

class HttpConnection;
typedef std::function<void(std::shared_ptr<HttpConnection>)> HttpHandler;
class HttpLogicSystem :public Singleton<HttpLogicSystem>
{
	friend class Singleton<HttpLogicSystem>;
public:
	~HttpLogicSystem();
	bool HandleGet(std::string, std::shared_ptr<HttpConnection>);
	void RegGet(std::string, HttpHandler handler);
	void RegPost(std::string, HttpHandler handler);
	bool HandlePost(std::string, std::shared_ptr<HttpConnection>);
private:
	HttpLogicSystem();
	std::map<std::string, HttpHandler> _post_handlers;
	std::map<std::string, HttpHandler> _get_handlers;
	NumericCodeGenerator _generator;
};